package com.zengqingfa.designpattern.structure.composite;

/**
 * @author zengqingfa
 * @className Leaf
 * @description
 * @create 2021/8/29 18:11
 */
public class Leaf implements Component {

    private String name;

    public Leaf(String name) {
        this.name = name;
    }

    @Override
    public void add(Component component) {
        throw new UnsupportedOperationException("叶子构件不支持此操作");
    }

    @Override
    public void remove(Component component) {
        throw new UnsupportedOperationException("叶子构件不支持此操作");
    }

    @Override
    public Component get(int i) {
        throw new UnsupportedOperationException("叶子构件不支持此操作");
    }

    @Override
    public void operation() {
        System.out.println("树叶" + name + "：被访问！");
    }
}